﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>    


<head>
<SCRIPT language=JAVASCRIPT src='<c:url value="/js/grid.js"/>'></SCRIPT>
	<script type="text/javascript">
		$(function(){
				init();
			
		});
		
			function init(){
				$('#t-dg').datagrid({
				loadMsg:''
				
			});
				
			}

		
		

		var actionUrl;
		function newItem(){
			$('#dlg').dialog('setTitle', '新增楼盘字典').dialog('open');
			$('#myform').form('clear');
			actionUrl = '<c:url value="/myinfo/Stzd/saveStzd"/>';
		}
		function editItem(){
			var t = $('#t-dg');
			if (isSingleSelect(t)){
			var row = t.datagrid('getSelected');
			if (row){
				$('#myform').form('load', row);
				$('#dlg').dialog('setTitle', '修改楼盘字典').dialog('open');
				actionUrl = '<c:url value="/myinfo/Stzd/updateStzd"/>?id=' + row.id;
			}
			}
		}
		
		function deleteItem(){
			var t = $('#t-dg');
			if (isSingleSelect(t)){
			var row = t.datagrid('getSelected');
			if (row){
				
				$.messager.confirm('删除确认', '是否确定要删除选择楼盘字典?', function(r){
						if (r){
				$.ajax({
					url:'<c:url value="/myinfo/Stzd/destroyStzd"/>?id=' + row.id,
					type:'post',
					success:function(){
						$('#t-dg').datagrid('reload');
					}
				});
			}});
				
			}
			}
		}
		
		function batpassItem(){
			var t = $('#t-dg');
			var rows = t.datagrid('getSelections');
			var ids = [];			
			if (rows){
				for(var i = 0, row; row = rows[i]; i++){
					ids.push(row.id);
				}
				
				$.messager.confirm('批量通过确认', '是否确定要批量通过选择楼盘字典?', function(r){
						if (r){
				$.ajax({
					url:'<c:url value="/myinfo/Stzd/batpassStzd"/>?ids=' + ids,
					type:'post',
					success:function(){
						$('#t-dg').datagrid('reload');
					}
				});
			}});
				
			}
		}
		
		function passItem(){
			var t = $('#t-dg');
			if (isSingleSelect(t)){
			var row = t.datagrid('getSelected');
			if (row){
				
				$.messager.confirm('通过确认', '是否确定要通过选择楼盘字典?', function(r){
						if (r){
				$.ajax({
					url:'<c:url value="/myinfo/Stzd/passStzd"/>?id=' + row.id,
					type:'post',
					success:function(){
						$('#t-dg').datagrid('reload');
					}
				});
			}});
				
			}
			}
		}
		
		
		function batunpassItem(){
			var t = $('#t-dg');
			var rows = t.datagrid('getSelections');
			var ids = [];			
			if (rows){
				for(var i = 0, row; row = rows[i]; i++){
					ids.push(row.id);
				}
				
				$.messager.confirm('批量不通过确认', '是否确定要批量不通过选择楼盘字典?', function(r){
						if (r){
				$.ajax({
					url:'<c:url value="/myinfo/Stzd/batunpassStzd"/>?ids=' + ids,
					type:'post',
					success:function(){
						$('#t-dg').datagrid('reload');
					}
				});
			}});
				
			}
		}
		
		function unpassItem(){
			var t = $('#t-dg');
			if (isSingleSelect(t)){
			var row = t.datagrid('getSelected');
			if (row){
				
				$.messager.confirm('不通过确认', '是否确定要不通过选择楼盘字典?', function(r){
						if (r){
				$.ajax({
					url:'<c:url value="/myinfo/Stzd/unpassStzd"/>?id=' + row.id,
					type:'post',
					success:function(){
						$('#t-dg').datagrid('reload');
					}
				});
			}});
				
			}
			}
		}
		
		function saveItem(){
			$('#myform').form('submit', {
				url:actionUrl,
				onSubmit:function(){
					return $('#myform').form('validate');
				},
				success:function(data){
					var data = eval('('+data+')');
					if (data.success){
						$('#dlg').dialog('close');
						$('#t-dg').datagrid('reload');
					} else {
						$.messager.show({
							title:'保存失败',
							msg:'<pre>'+data.msg+'</pre>'
						});
					}
				}
			});
		}
		function doQuery(value){
			$('#t-dg').datagrid('load', {
				q: value
			});
		}
		
		
		function formatpassflag(value){
			if (value == "-1") 
				return "<font color=red>未通过</font>";
			if (value == "0") 
				return "<font color=blue>通过</font>";

			}
	</script>
</head>
<body>
	<div class="easyui-layout" fit="true">
		<div region="north" border="false" style="height:40px;padding:5px;overflow:hidden;">
		<div style="padding-top:3px;float:left">
			<input class="easyui-searchbox" prompt="按关键字进行查询" searcher="doQuery" style="width:300px"></input>
			</div>
			<div style="float:left">
			<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newItem()">新增楼盘</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editItem()">修改楼盘</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deleteItem()">删除楼盘</a>
			</div>
			
			<c:if test="${passmode == 'true'}">	
			<div style="float:right">		
			<a href="#" class="easyui-linkbutton" iconCls="icon-ok" plain="true" onclick="batpassItem()">批量通过审核</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="batunpassItem()">批量取消通过</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-ok" plain="true" onclick="passItem()">通过审核</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="unpassItem()">取消通过</a>
			</div>
			</c:if>
			
		</div>
		
		
		<div region="center" border="true">
			<table id="t-dg" style="display:none;"
					url="<c:url value='/myinfo/Stzd/getStzdItems'/>"
					 rownumbers="true" pagination="true"
					border="false" fit="true" fitColumns="true">
				<thead>
					<tr>
					<th field="ck" checkbox="true"></th>
						<th field="py" width="100" sortable="true">拼音缩写</th>
						<th field="fullpy" width="120" sortable="true">拼音</th>
<th field="dz" width="150"  sortable="true">地址</th>
<th field="qy" width="60"  sortable="true">区域</th>
<th field="inputdate" width="120"  sortable="true">创建时间</th>
<th field="editdate" width="120"  sortable="true">修改时间</th>
<th field="passflag" width="60"  formatter="formatpassflag" sortable="true">审核</th>
<th field="unitname" width="100" sortable="true">单位名称</th>
<th field="oper" width="80" sortable="true">操作人员</th>

					</tr>
				</thead>
			</table>
		</div>
	</div>
	
<div id="dlg" style="width:400px;height:250px;"
			class="easyui-dialog" closed="true" modal="true" buttons="#dlg-buttons">
		<div style="padding:10px">
			<div style="float:left">
				<form id="myform" method="post" style="margin:0;padding:0">
					<table>
						<tr>
<td style="width:80px">地址</td>
<td><input type="text" class="easyui-validatebox e-input" id="dz" name="dz" style="width:250px;" data-options="required:false,editable:true" ></input></td>
</tr>	
<tr>
<td style="width:80px">区域</td>
<td><input type="text" class="e-input" id="qy" name="qy" style="width:250px;" ></input>
</td>
</tr>	
<tr>
<td style="width:80px"></td>
<td>
<a href="javascript:selectmap2();" class="easyui-linkbutton"  plain="true" data-options="iconCls:'icon-search'">选择</a>  
</td>
</tr>	
								
					</table>
				</form>
			</div>			
			<div style="clear:both"></div>
		</div>
		<div id="dlg-buttons" style="text-align:center;">
			<a href="#" class="easyui-linkbutton" iconCls="icon-save" onclick="saveItem()">保存</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
		</div>
</div>

<script>


		
function selectmap2(){
	parent.selectmap('<c:url value="/"/>', function(maps){
		var tab = $('#tt').tabs('getSelected');
	    var _refresh_ifram = tab.find('iframe')[0];
	    $(_refresh_ifram.contentWindow.document).contents().find('#qy').val(maps[0]);
		
			},$('#qy').val(),false,true);
	
	};	
</script>		

</body>
